package monitorlog

import (
	"os"
	"github.com/astaxie/beego/logs"
)

// 记录monitor相关新的

const (
	MonitorCmdLog = "CMD"
	MonitorFileLog = "FILE"
	MonitorLogCollector = "Log"
)

const (
	CmdLogType = 10000001
	FileLogType = 10000002
)

var MonLogFd = logs.NewLogger()

func init()  {
	logDir := "./var"

	_, err := os.Stat(logDir)
	if err != nil {
		err = os.Mkdir(logDir, 0600)
		if err != nil {
			panic(err)
		}

		// 单个文件最大支持2G
		MonLogFd.SetLogger(logs.AdapterFile, `{"filename": "var/monitor.log", "maxlines":0,"maxsize":2147483648,"daily":true,"maxdays":2}`)
	} else {
		MonLogFd.SetLogger(logs.AdapterFile, `{"filename": "var/monitor.log", "maxlines":0,"maxsize":2147483648,"daily":true,"maxdays":2}`)
	}
	return
}